//使用vuex来保存用户信息
import { mapActions, mapState } from 'vuex'
import {requestLogin, checkLogin} from "../../../api/api"
import qs from "qs";
export default {
  data() {
    return {
      cilentHeight: 0,
      form: {
        name: '',
        codeword: '',
        rememberme: false
      },
      vaildcode: null,
    }
  },
  mounted() {
    //设定一个高度
    let cilentHeight1 = document.documentElement.clientHeight
    this.cilentHeight = cilentHeight1;
    // checkLogin().then(data => {
    //   let {msg, code, user} = data;
    //   if (code == "1") {
    //     if (localStorage.logincount) {
    //       localStorage.logincount = Number(localStorage.logincount) + 1;
    //     } else {
    //       localStorage.logincount = 1;
    //     }
    //     if (Number(localStorage.logincount) < 3) {
    //       window.location.href = process.env.API_ROOT + '/login/cas';
    //     } else {
    //       alert("单点登录次数过多");
    //       localStorage.logincount = 0;
    //     }
    //   } else {
    //     localStorage.logincount = 0;
    //     sessionStorage.setItem('user', user);
    //     this.$router.push({path: '/'});
    //   }
    // }).catch(error => {
    //   console.log(error);
    // })
  },
  methods: {
    submitLogin (data) {
      let _this = this
      this.doLogin({ _this, data })
    },
    changeRememberme (value) {
      CacheUtil.setLocalStorage(Constant.REMEMBERME, value)
    },
    ...mapActions('account', [
      'doLogin'
    ])
  }
}
